package br.com.ss.portal.controller.eleitor;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import br.com.ss.portal.model.dao.IEleitorDAO;
import br.com.ss.portal.model.dao.IResponsavelDAO;
import br.com.ss.portal.model.entity.Eleitor;
import br.com.ss.portal.model.entity.Responsavel;

@Service
@Transactional
public class EleitorService implements IEleitorService {

	@Autowired
	private IEleitorDAO ieleitorDAO;
	
	@Autowired
	private IResponsavelDAO iResponsavelDAO;

	@Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false)
	public void salvar(Eleitor eleitor) {
		ieleitorDAO.save(eleitor);
	}

	@Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false)
	public void deletar(Eleitor eleitor) {
		ieleitorDAO.delete(eleitor);
	}

	public List<Eleitor> Buscartodos() {
		return ieleitorDAO.getALL();
	}
	
	public List<Responsavel> listResponsavel() {
		return iResponsavelDAO.getALL();
	}

}
